import { ElMessage } from "element-plus";

const showMessage = (msg?: string, callback?: Callback, type?: MessageType) => {
  ElMessage({
    type: type,
    message: msg,
    duration: 2000,
    onClose: () => {
      if (callback) {
        callback();
      }
    },
  });
};

const message: Message = {
  error: (msg, callback) => showMessage(msg, callback, "error"),
  success: (msg, callback) => showMessage(msg, callback, "success"),
  warning: (msg, callback) => showMessage(msg, callback, "warning"),
};

export default message;